#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int a, b;
	cin>>s>>a>>b;
	a = s[a-1];
	b = s[b-1];
	sort(s.begin(), s.end());
	int idx1, idx2;
	idx1 = upper_bound(s.begin(), s.end(), a)-s.begin();
	idx2 = upper_bound(s.begin(), s.end(), b)-s.begin();
	if(idx1 >= s.size() || idx2 >= s.size())
		cout<<"0";
	else
		cout<<(s[idx1]-'0')+(s[idx2]-'0');
	return 0;
}
